#define _CRT_SECURE_NO_WARNINGS 1
#include"Queue.h"
void QueueInit(Queue* q)
{
	q->phead = q->ptail = NULL;
	q->size = 0;
}
void QueuePush(Queue* q, QDataType data)
{
	assert(q);
	QueueNode* newNode = (QueueNode*)malloc(sizeof(QueueNode));
	newNode->next = NULL;
	newNode->val = data;

	if (q->size == 0)
	{
		q->phead = q->ptail=newNode;
		
	}
	else
	{
		q->ptail->next = newNode;
		q->ptail = newNode;
	}
	q->size++;
}
void QueuePop(Queue* q)
{
	assert(q);
	assert(q->size);
	if (q->phead->next == NULL)
	{
		free(q->phead);
		q->phead = q->ptail = NULL;
	}
	else
	{
		QueueNode* del = q->phead;
		q->phead = q->phead->next;
		free(del);
		del = NULL;
	}
	q->size--;
}
QDataType QueueFront(Queue* q)
{
	assert(q);
	assert(q->size);
	return q->phead->val;
}
QDataType QueueBack(Queue* q)
{
	assert(q);
	assert(q->size);
	return q->ptail->val;
}